﻿using System.Data;
using System.Globalization;
using Pantry.Commons;
using Pantry.DataAccess;

namespace Pantry.Business
{
    public class TrustDistrictBus:PantryBus
    {
        public TrustDistrictBus()
        {
            PantryDao = new TrustDistrictDao();
        }

        public DataSet SelectAll()
        {
            return ((TrustDistrictDao)PantryDao).SelectAll();
        }

        public DataTable RetrieveTrustDistrictsByRegion(int regionId)
        {
            if (regionId<1)
            {
                return null;
            }

            var dataTable = RetrieveData("TrustRegionId", regionId.ToString(CultureInfo.InvariantCulture), SqlDbType.Int);
            if (dataTable==null)
            {
                return null;
            }
            string description;
            foreach (DataRow dataRow in  dataTable.Rows)
            {
                description = dataRow["Description"].ToString();
                dataRow["Description"] = Validates.TrimDescription(description, 50);
            }

            return dataTable;
        }

    }
}
